home *** CD-ROM | disk | FTP | other *** search
/ Aminet 4 / Aminet 4 - November 1994.iso / aminet / dev / gcc / libnix.lha / gnu / lib / libnix / sources.lha / nix / string / strrchr.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-06-09  |  438 b   |  36 lines

  1. #ifndef mc68000
  2.  
  3. #include <stdio.h>
  4. #include <string.h>
  5.  
  6. asm(".globl _rindex;_rindex:;jmp pc@(_strrchr-.+2)");
  7.  
  8. char *strrchr(const char *s,int c)
  9. { char *c1=NULL;
  10.   do
  11.     if(*s==(char)c)
  12.       c1=(char *)s;
  13.   while(*s++!='\0');
  14.   return c1;
  15. }
  16.  
  17. #else
  18.  
  19. asm("
  20.     .globl    _rindex
  21.     .globl    _strrchr
  22. _rindex:
  23. _strrchr:
  24.     movel    sp@(4:W),a1
  25.     movel    sp@(8:W),d1
  26.     moveq    #0,d0
  27. L2:    cmpb    a1@,d1
  28.     jne    L1
  29.     movel    a1,d0
  30. L1:    tstb    a1@+
  31.     jne    L2
  32.     rts
  33. ");
  34.  
  35. #endif
  36.